package GUI;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import java.util.ArrayList;

import logic.Member;
import logic.SystemMesseges;
import javax.swing.UIManager;
import javax.swing.border.MatteBorder;
import java.awt.SystemColor;

public class Home extends JPanel {

	private Client_GUI parent;
	
	public Home(Client_GUI parent,ArrayList<SystemMesseges> publicMessages) {
		this.parent = parent;
		
		this.setSize(parent.MAIN_WIDTH, parent.MAIN_HEIGHT);
		setLayout(null);
		this.setBackground(UIManager.getColor("inactiveCaption"));
		
		JLabel lblWelcome = new JLabel();
		lblWelcome.setForeground(SystemColor.textHighlight);
		lblWelcome.setBounds(233, 30, 328, 50);
		lblWelcome.setFont(new Font("Tahoma", Font.BOLD, 20));
		add(lblWelcome);
		
		String title = "";
		
		switch(parent.client.Privelege){
		case  Member.SYSTEM_USER_PRIVILIGE:{
			title = "Hello System User!";
			break;
		}
		case  Member.MANAGER_PRIVILIGE:{
			title = "Manager User!";
			break;
		}
		case  Member.LIBRARIAN_PRIVILIGE:{
			title = "Librarian User!";
			break;
		}
		case  Member.MEMBER_PRIVILIGE:{
			title = "Member User!";
			break;
		}
		
		}
		lblWelcome.setText(title);

		
		JPanel panel = new JPanel();
		panel.setBorder(new MatteBorder(2, 2, 2, 2, (Color) new Color(0, 0, 0)));
		panel.setBounds(61, 91, 685, 398);
		add(panel);
		panel.setLayout(null);
		
		ArrayList<JLabel> msgLbls = new ArrayList<JLabel>();
		
		JLabel L1 = new JLabel("");
		L1.setForeground(Color.BLACK);
		L1.setFont(new Font("Tahoma", Font.BOLD, 18));
		L1.setBounds(45, 47, 594, 40);
		panel.add(L1);
		msgLbls.add(L1);
		
		JLabel L2 = new JLabel("");
		L2.setForeground(Color.BLACK);
		L2.setFont(new Font("Tahoma", Font.BOLD, 18));
		L2.setBounds(45, 98, 594, 40);
		panel.add(L2);
		msgLbls.add(L2);
		
		JLabel L3 = new JLabel("");
		L3.setForeground(Color.BLACK);
		L3.setFont(new Font("Tahoma", Font.BOLD, 18));
		L3.setBounds(45, 149, 594, 40);
		panel.add(L3);
		msgLbls.add(L3);

		JLabel L4 = new JLabel("");
		L4.setForeground(Color.BLACK);
		L4.setFont(new Font("Tahoma", Font.BOLD, 18));
		L4.setBounds(45, 200, 594, 40);
		panel.add(L4);
		msgLbls.add(L4);
		
		JLabel L5 = new JLabel("");
		L5.setForeground(Color.BLACK);
		L5.setFont(new Font("Tahoma", Font.BOLD, 18));
		L5.setBounds(45, 251, 594, 40);
		panel.add(L5);
		msgLbls.add(L5);
		
		JLabel L6 = new JLabel("");
		L6.setForeground(Color.BLACK);
		L6.setFont(new Font("Tahoma", Font.BOLD, 18));
		L6.setBounds(45, 302, 594, 40);
		panel.add(L6);
		msgLbls.add(L6);
		
		for(JLabel label : msgLbls){
			label.setText("");
		}
		
		if (publicMessages != null){
			for(int i=0; i<publicMessages.size(); i++){
				if (i == 5) break;
				msgLbls.get(i).setText(publicMessages.get(i).getMESSAGE());
			}
		}
		
	}

	
	
}
